﻿package dk.gaming.rummikub.events
{
	import flash.events.Event;
	import dk.gaming.rummikub.primitive.Tile;
	import dk.gaming.rummikub.backend.Table;
	import dk.gaming.rummikub.complexeventresult.ProxyEventResult;
	
	public class ProxyEvent extends Event
	{
		
		public var request : String;
		public var result : String;
		public var tile:Tile;
		public var gamelist : Array;
		public var table : Table;
		public var userID : String;
		public var gameID : String;
		
		public var proxyresult : ProxyEventResult;
		public var universal : Object;
		
		public static var LOGIN_REQUEST_RESULT : String = "peLoginRequestResult";
		public static var GAME_LIST_RESPONSE : String = "peGetGameListResponse";
		public static var JOIN_GAME_REQUEST_RESULT : String = "peJoinGameRequestResult";
		public static var NEW_TABLE_CREATION_RESPONSE : String = "peNewTableCreationResponse";
		public static var NEW_TILE_RESPONSE : String = "peNewTileResponse";
		public static var END_SET_RESPONSE : String = "peEndSetResponse";
		public static var GAME_START : String = "peGameStart";
		public static var TILE_RELEASE : String = "peTileRelease";
		public static var TABLE_TILE_HARVESTED : String = "peTableTileHarvested";
		public static var TURN_END : String = "peTurnEnd";
		public static var JOKER_SET : String = "peJokerSet";
		public static var STARTER_SET : String = "peStarterSet";
		public static var GAME_END_BY_WIN : String = "peGameEndByWin";
		public static var GAME_END_UNEXPECTED : String = "peGameEndUnexpected";
		public static var INCOMING_MESSAGE : String = "peIncomingMessage";
		public static var PROXY_ERROR : String = "peProxyError";
	
		
		
		
		public function ProxyEvent(type:String,
								   bubbles:Boolean = false,
								   cancelable : Boolean = false,
								   $request:String="",
								   $result:String="",
								   $tile:Tile=null,
								   $gamelist:Array=null,
								   $table:Table=null,
								   $userID:String="",
								   $gameID:String="") 
			{
			super(type,bubbles,cancelable);
			this.request = $request;
			this.result = $result;
			this.tile = $tile;
			this.gamelist = $gamelist;
			this.table = $table;
			this.userID = $userID;
			this.gameID = $gameID;
		}
		
		override public function clone():Event
		{
			return new ProxyEvent(type, bubbles, cancelable, request, result, tile, gamelist, table, userID, gameID);
		}
		
		override public function toString():String
		{
			return "request : "+request+" and result : "+result;
		}
		
	}
	
}